Skip to main content

Planetary-Specific Scripts

Specialized utilities for planetary science data processing, including slope analysis, coordinate system definitions, and format conversions.

gdal_baseline_slope.py

Calculates slope from DEMs using specialized baseline lengths or Horn’s method.

Usage

Parameters

string
required
Input DEM file
string
required
Output slope file (GeoTIFF)

Options

integer
Baseline length in pixels for slope calculation. If not specified, uses Horn’s method (equivalent to gdaldem slope).
datatype
Output data type (default: same as input)Options: Byte, Int16, UInt16, Int32, UInt32, Float32, Float64
flag
Crop output to remove edge effects from baseline calculation
flag
Quiet mode - suppress progress output

Slope Calculation Methods

Horn’s Method (Default)

When -baseline is not specified:
  • Uses 3x3 kernel (standard GIS slope calculation)
  • Equivalent to gdaldem slope
  • No shift in geotransform

Baseline Method

When -baseline N is specified:
  • Uses corner points of N×N footprint
  • Follows Kirk’s method for planetary analysis
  • Even baselines shift geotransform by half pixel

Byte Output Scaling

When -ot Byte is used:
  • Slopes are scaled to 1-255 range
  • Formula: DN = (slope + 0.2) × 5.0
  • Slopes >50° map to 255
  • NoData = 0
  • Set offset = -0.2, scale = 0.2 in output

Example

Cropping Behavior

When -crop is used with -baseline:

Requirements

Dependencies:
  • Python 2.7+ or Python 3.x
  • GDAL Python bindings
  • NumPy
  • SciPy (for generic_filter)

create_IAU2000_wkt_v3.py

Generates OGC WKT (Well-Known Text) projection strings for IAU planetary coordinate systems.

Usage

Parameters

string
required
Input CSV file with IAU body radiiMust be named: naifcodes_radii_m_wAsteroids_IAU{YEAR}.csvSupported years: 2000, 2009, 2015
string
Output WKT file (default: stdout)

Input CSV Format

Generated Coordinate Systems

For each body, generates multiple coordinate system definitions:

Geographic Systems

  • X00 - Planetocentric
  • X01 - Planetographic

Static Projections

  • X10-X13 - Equirectangular (ocentric/ographic, clon 0/180)
  • X14-X17 - Sinusoidal (ocentric/ographic, clon 0/180)
  • X18-X21 - Polar Stereographic (North/South, ocentric/ographic)
  • X22-X29 - Mollweide and Robinson variants

AUTO Projections (Variable Center)

  • X60-X61 - Sinusoidal AUTO
  • X62-X63 - Stereographic AUTO
  • X64-X65 - Transverse Mercator AUTO
  • X66-X67 - Orthographic AUTO
  • X68-X69 - Equirectangular AUTO
  • X70-X71 - Lambert Conformal Conic AUTO
  • X72-X73 - Lambert Azimuthal Equal Area AUTO
  • X74-X75 - Mercator AUTO
  • X76-X77 - Albers AUTO
  • X78-X79 - Oblique Cylindrical Equal Area AUTO
  • X80-X83 - Mollweide and Robinson AUTO
Where X = NAIF_ID * 100 + code

Example

Output Format

Use Cases

  • Configuring WMS/WCS services for planetary data
  • Creating custom projections for planetary mapping
  • Supporting GDAL/MapServer planetary coordinate systems
  • Generating ESRI .prj files for planetary data

IAU Reports Supported

  • IAU 2000 - Seidelmann et al. (2002)
  • IAU 2009 - Archinal et al. (2011)
  • IAU 2015 - Archinal et al. (2018)

isis3_to_pds4_LOLA_pvl.py

Converts ISIS3 cube labels to PDS4 format using GDAL’s PDS4 driver.

Usage

Parameters

string
required
Input ISIS3 cube file
string
required
Output GDAL configuration file for PDS4 conversion

Options

flag
Automatically execute gdal_translate after creating config
string
Path to custom PDS4 XML templateDefault: $GDALDATA/pds4_template.xml

How It Works

  1. Reads ISIS3 label using Python PVL library
  2. Extracts metadata: target, mission, instrument, product ID
  3. Creates GDAL configuration file with PDS4 variables
  4. Optionally runs gdal_translate to create PDS4 product

Output Files

Generated configuration file contains:

Example

Manual Conversion

After creating config file:

Requirements

Dependencies:
  • Python 3.x
  • GDAL 2.2.0+ with PDS4 driver support
  • PVL library: pip install pvl

fix_jp2_v2

Corrects GeoJP2 projection keywords for Equirectangular projections (C++ utility).

Purpose

Fixes HiRISE and other JPEG2000 files where CenterLatGeoKey was incorrectly used instead of StandardParallel1GeoKey in Equirectangular projections.

Usage

Parameters

string
required
Input/output JPEG2000 file to fix (modified in place)

How It Works

  1. Opens the JPEG2000 file
  2. Locates the GeoTIFF metadata section
  3. Changes CenterLatGeoKey tag to StandardParallel1GeoKey
  4. Writes changes (only a few bytes modified)
  5. Does not decompress/recompress imagery

Safety

Version 2 update (Jan 10, 2023):
  • Skips files already corrected by HiRISE team
  • Only modifies files that need correction
  • Always backup files before running

Example

Compilation

Use Cases

  • Fixing older HiRISE JPEG2000 files
  • Correcting GeoJP2 files with incorrect projection parameters
  • Batch processing of archived data

Technical Details

Addresses GDAL ticket: http://trac.osgeo.org/gdal/ticket/2706

Common Workflows

Planetary Slope Analysis Workflow

PDS4 Archive Workflow

Requirements

All planetary scripts require:
  • Python 2.7+ or Python 3.x (varies by script)
  • GDAL/OGR Python bindings
  • Script-specific dependencies (NumPy, SciPy, pvl)

Author

Developed by Trent Hare and contributors at USGS Astrogeology Science Center.

License

Public domain (Unlicense) unless otherwise specified.